const app = getApp()
import Dialog from '@vant/weapp/dialog/dialog';
import {
  showMsg
} from '../../../../utils/config.js'
import {
  reqMessagePackage,
  reqVoicePackage
} from '../../../../request/api'
let behaviorsOrgSelection = require('../../../../pages/behaviors/org/orgSelection.js')
Page({
  behaviors: [behaviorsOrgSelection],
  data: {
    navHeight: app.globalData.navHeight + 'px', //头部距离
    bottomHeight: app.globalData.bottomHeight + 'px', //iphone底部距离

    showUnitSelection: false,

    message: 0,
    voice: 0,
  },
  onLoad(e) {},
  onShow() {
    // this.getMessagePackage()
    // this.getVoicePackage()
  },
  async getMessagePackage() {
    const res = await reqMessagePackage(this.data.orgInfo.orgId)
    if (res.code !== 20000) return showMsg(res.message)
    this.setData({
      message: res.data.sum || 0
    })
  },
  async getVoicePackage() {
    const res = await reqVoicePackage(this.data.orgInfo.orgId)
    if (res.code !== 20000) return showMsg(res.message)
    this.setData({
      voice: res.data.sum || 0
    })
  },

  // 单位选择确定
  confirmUnit() {
    if (!this.data.orgInfo.orgId) return
    this.getMessagePackage()
    this.getVoicePackage()
  },
})